package be.dch.objectprops.impl;

import org.apache.log4j.Logger;

import be.dch.objectprops.ParserFinder;

import com.google.inject.Inject;

public class ObjectWriter {

    private static final Logger LOG = Logger.getLogger(ObjectWriter.class);

    @Inject
    private ParserFinder finder;
    private transient String inputPrefix;

    public void writeObject(final Object result) {
	ObjectWriter.LOG.debug("Writing object " + result.toString());
	this.inputPrefix = result.getClass().getSimpleName();
	this.finder.write(result, new StringBuilder(this.inputPrefix));
    }

    public void writeObject(final String prefix, final Object result) {
	ObjectWriter.LOG.debug("Writing object " + result.toString());
	this.inputPrefix = prefix;
	this.finder.write(result, new StringBuilder(this.inputPrefix));
    }

}
